<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" 
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml"
	xmlns:h="http://java.sun.com/jsf/html"
	xmlns:ui="http://java.sun.com/jsf/facelets"
	xmlns:p="http://primefaces.org/ui"
	xmlns:f="http://java.sun.com/jsf/core">
<h:body>
	<ui:composition template="/WEB-INF/templates/template.xhtml">
		<ui:define name="content">
			<h:form id="form">
				<p:growl id="growl" sticky="false" autoUpdate="true"
					showDetail="true" />
				<p:panel header="#{msg_e.title_cat_tab_a}">
					<p:commandButton value="#{msg_e.new}" icon="ui-icon-plusthick"
						onclick="PF('dlgNew').show();" update=":formNew:panelgrid_new" />
					<p:commandButton value="#{msg_e.ver}" icon="ui-icon-search"
						oncomplete="PF('dlgView').show();"
						update=":formView:panelgrid_view" />
					<p:commandButton value="#{msg_e.edit}" icon="ui-icon-pencil"
						onclick="PF('dlgEdit').show();" update=":formEdit:panelgrid_edit" />
					<p:commandButton value="#{msg_e.delete}" icon="ui-icon-trash"
						onclick="PF('dlgDelete').show();" />
					<br />
					<p:dataTable value="#{ta_controller.itemsList}" var="item"
						rows="10" paginator="true"
						currentPageReportTemplate="{startRecord} de {endRecord}"
						paginatorTemplate="{CurrentPageReport}  {FirstPageLink} {PreviousPageLink} {PageLinks} {NextPageLink} {LastPageLink} {RowsPerPageDropdown}"
						rowsPerPageTemplate="5,10,15" paginatorPosition="bottom"
						resizableColumns="true" selection="#{ta_controller.currentItem}"
						rowKey="#{item.idField}" id="table">
						<p:column selectionMode="single"
							style="width:16px;text-align:center" />
						<p:column headerText="#{msg_e.id}" sortBy="#{item.idField}"
							filterBy="#{item.idField}">
							<h:outputText value="#{item.idField}" />
						</p:column>
						<p:column headerText="#{msg_e.dsc}" sortBy="#{item.description}"
							filterBy="#{item.description}">
							<h:outputText value="#{item.description}" />
						</p:column>
						<p:column headerText="#{msg_e.val}" sortBy="#{item.value}"
							filterBy="#{item.value}">
							<h:outputText value="#{item.value}" />
						</p:column>
					</p:dataTable>
				</p:panel>
			</h:form>
			<!-- Panel for view -->
			<p:dialog header="#{msg_e.detail}" widgetVar="dlgView"
				style="position:fixed;">
				<h:form id="formView">
					<p:outputPanel id="outputPanel_view">
						<h:panelGrid columns="2" id="panelgrid_view">
							<p:outputLabel value="#{msg_e.id}" for="current_item_view_id" />
							<h:outputText value="#{ta_controller.currentItem.idField}"
								id="current_item_view_id" />
							<p:outputLabel value="#{msg_e.dsc}" for="current_item_view_dsc" />
							<h:outputText value="#{ta_controller.currentItem.description}"
								id="current_item_view_dsc" />
							<p:outputLabel value="#{msg_e.val}" for="current_item_view_value" />
							<h:outputText value="#{ta_controller.currentItem.value}"
								id="current_item_view_value" />
						</h:panelGrid>
						<div style="float: right;">
							<p:commandButton value="#{msg_e.accept}"
								onclick="PF('dlgView').hide();" type="button"
								icon="ui-icon-check" />
						</div>
					</p:outputPanel>
				</h:form>
			</p:dialog>
			<!-- End panel for view -->
			<!-- Panel for edit -->
			<p:dialog header="#{msg_e.edit}" widgetVar="dlgEdit" modal="true"
				style="position:fixed;">
				<h:form id="formEdit">
					<p:outputPanel id="outputPanelEdit">
						<h:panelGrid columns="3" id="panelgrid_edit">
							<p:outputLabel value="#{msg_e.id}" for="current_item_edit_id" />
							<h:outputText value="#{ta_controller.currentItem.idField}"
								id="current_item_edit_id" />
							<h:outputText value="" />
							<p:outputLabel value="#{msg_e.dsc}" for="current_item_edit_dsc" />
							<p:inputText value="#{ta_controller.input_edit_dsc}"
								id="current_item_edit_dsc" />
							<p:watermark value="#{ta_controller.currentItem.description}"
								for="current_item_edit_dsc" />
							<p:outputLabel value="#{msg_e.val}" for="current_item_edit_value" />
							<p:inputText value="#{ta_controller.input_edit_val}"
								id="current_item_edit_value" />
							<p:watermark value="#{ta_controller.currentItem.value}"
								for="current_item_edit_value" />
						</h:panelGrid>
						<h:panelGrid columns="2">
							<p:commandButton value="#{msg_e.accept}"
								oncomplete="handlRequest(xhr, status, args, 'dlgEdit')"
								icon="ui-icon-check"
								actionListener="#{ta_controller.onEditTableA}"
								update=":form:table" />
							<p:commandButton value="#{msg_e.cancel}"
								onclick="PF('dlgEdit').hide();" icon="ui-icon-close"
								actionListener="#{ta_controller.onEditCancelTableA}"
								immediate="true" />
						</h:panelGrid>
					</p:outputPanel>
				</h:form>
			</p:dialog>
			<!-- End panel for edit -->
			<!-- Panel for new -->
			<p:dialog header="#{msg_e.new}" widgetVar="dlgNew" modal="true"
				style="position:fixed;">
				<h:form id="formNew">
					<p:outputPanel id="outputPanelNew">
						<p:focus context=":formNew:outputPanelNew" />
						<h:panelGrid columns="3" id="panelgrid_new">
							<p:outputLabel value="#{msg_e.dsc}" for="current_item_new_dsc"
								style="tex-align:left;" />
							<p:inputText value="#{ta_controller.input_new_dsc}"
								id="current_item_new_dsc" required="true" label="#{msg_e.dsc}"
								requiredMessage="#{msg_e.required_input_dsc}" />
							<p:message for="current_item_new_dsc" />
							<p:outputLabel value="#{msg_e.val}" for="current_item_new_value" />
							<p:inputText value="#{ta_controller.input_new_val}"
								required="true" requiredMessage="#{msg_e.required_input_val}"
								id="current_item_new_value" label="#{msg_e.val}" />
							<p:message for="current_item_new_value" />
						</h:panelGrid>
						<h:panelGrid columns="2">
							<p:commandButton value="#{msg_e.accept}"
								oncomplete="handlRequest(xhr, status, args, 'dlgNew')"
								icon="ui-icon-check"
								actionListener="#{ta_controller.onSaveTableA}"
								update=":form:table :formNew:panelgrid_new" />
							<p:commandButton value="#{msg_e.cancel}"
								onclick="PF('dlgNew').hide();" icon="ui-icon-close"
								immediate="true"
								actionListener="#{ta_controller.onSaveCancelTableA}" />
						</h:panelGrid>
					</p:outputPanel>
				</h:form>
			</p:dialog>
			<!-- End panel for new -->
			<!-- Panel for delete -->
			<p:confirmDialog widgetVar="dlgDelete" resizable="false"
				header="#{msg_e.action_confirm}"
				message="#{msg_e.delete_item_message}">
				<h:form id="formDelete">
					<p:commandButton value="#{msg_e.accept}" update=":form:table"
						styleClass="ui-confirmdialog-yes" icon="ui-icon-check"
						oncomplete="PF('dlgDelete').hide();"
						actionListener="#{ta_controller.onDeleteTableA}" />
					<p:commandButton value="#{msg_e.cancel}"
						onclick="PF('dlgDelete').hide();" immediate="true"
						actionListener="#{ta_controller.onDeleteCancelTableA}"
						styleClass="ui-confirmdialog-no" icon="ui-icon-close" />
				</h:form>
			</p:confirmDialog>
			<!-- End panel for delete -->
		</ui:define>
	</ui:composition>

</h:body>
</html>